import logging

logging.warning("warning:user/passwd is invalid")
logging.critical("critical:server is down")

logging.basicConfig(filename='access.log',level=logging.ERROR,format='%(asctime)s %(message)s',
 datefmt='%m/%d/%Y %I:%M:%S %p')

 #basicConfig 方法对日志进本信息进行配置，文件名、日志级别、输出格式等，但必须以key-value形式使用
logging.debug('This message should go to the log file?') # 由于上面已经将日志级别设置为INFO，故低于INFO的不会被打印
logging.info('So should this')
logging.warning('And this, too')
'''
debug(), info(), warning(), error() and critical()5个级别
'''

print(logging.DEBUG)